<template>
	<view>
		<uni-data-picker :localdata="styleNoSelectList"
			:popup-title="$t('public.pleaseSelect')+$t('public.styleNo')" @change="styleNoChange">
			<search :placeholder="$t('public.styleNo')" />
		</uni-data-picker>
		<!-- 工艺流程 -->
		<zy-group :title="$t('homepage.ProcessQuery.techProcess')">
			<zy-table :headList="headList" :dataList="dataList" border></zy-table>
		</zy-group>
		<!-- 工艺指导 -->
		<zy-group :title="$t('homepage.ProcessQuery.techGuide')">
			<view class="formList" v-for="item in fileList" :key="item.key">
				{{item.name}}
			</view>
		</zy-group>
		<!-- 底部按钮 -->
		<bottomBtn fixed :leftText="$t('public.reset')" :rightText="$t('homepage.ProcessQuery.part')"
			@rightBtn="partBtn" @leftBtn="resetBtn">
		</bottomBtn>
		<zy-popup ref="popup" :title="$t('homepage.ProcessQuery.partSelect')" type="dialog"
			:rightBtn="$t('public.sure')" @confirm="confirm">
			<zy-select :selectList="partSelectList" @lineHandler="partChange" clearable>
			</zy-select>
		</zy-popup>
	</view>
</template>
<script>
	import {
		getStyleByCode,
		getStyleBySeach,
	} from "@/api/homepage.js"
	export default {
		data() {
			return {
				model: {
					style: '',
					part: ''
				},
				styleNoSelectList: [],
				partSelectList: [],
				//表格表头
				headList: [{
					name: this.$t('public.procedureCode'),
					key: 'id',
				}, {
					name: this.$t('public.procedureName'),
					key: 'name',
				}, {
					name: this.$t('public.part'),
					key: 'part',
				}, {
					name: this.$t('homepage.ProcessQuery.check'),
					key: 'check',
				}],
				dataList: [], //表格数据
				fileList: [],
			}
		},
		onLoad: function(option) {
			setTimeout(() => {
				let arr = JSON.parse(option.data)
				this.dataList = arr.tableData
				this.fileList = arr.file
			}, 500)
		},
		methods: {
			//获取弹框数据
			searchList(e) {
				this.styleNoSelectList = []
				getStyleByCode({
					code: e
				}).then((res) => {
					if (res.code == 0) {
						// 款式下拉框数组数据
						this.styleNoSelectList = res.data
					} else {
						uni.showToast({
							title: res.message,
							icon: "none",
							duration: 3000
						})
					}
				}).catch((res) => {
					uni.showToast({
						title: res.message,
						icon: "none",
						duration: 3000
					})
				});
			},
			// 获取款号事件
			styleNoChange(e) {
				this.model.style = e.detail.value[0].value
			},
			// 获取部件事件
			partChange(e) {
				this.model.part = e
			},
			//重置
			resetBtn() {
				uni.redirectTo({
					url: "/pages/HomePage/ProcessQuery/index"
				})
			},
			// 部件下拉查询
			partBtn() {
				this.$refs.popup.open()
				// getStyleBySeach({}).then((res) => {
				// 	if (res.code == 0) {

				// 	} else {
				// 		uni.showToast({
				// 			title: res.message,
				// 			icon: "none",
				// 			duration: 3000
				// 		})
				// 	}
				// }).catch((res) => {
				// 	uni.showToast({
				// 		title: res.message,
				// 		icon: "none",
				// 		duration: 3000
				// 	})
				// });
			},
			confirm() {
				this.$refs.popup.close()
			}
		}
	}
</script>
<style lang="scss" scoped>
</style>